﻿
namespace EasyNet.Solr.Commons
{
    using System.Runtime.InteropServices;

    [StructLayout(LayoutKind.Explicit)]
    public struct FloatConverter
    {
        [FieldOffset(0)]
        private float f;
        [FieldOffset(0)]
        private int i;

        public static float ToFloat(int value, ref FloatConverter converter)
        {
            converter.i = value;

            return converter.f;
        }

        public static int ToInt(float value, ref FloatConverter converter)
        {
            converter.f = value;

            return converter.i;
        }

    }
}
